<?
//inculde即可以使用data数据。本页所有的data数据，倾在controller都处理好
include_once("../../../common/module/checkA.php");
include_once("../../../../config.php");
?>


<?php
//接收需要修改的数据的id
$new_detail_nid          = addslashes($_REQUEST['nid']);


//传递过来的页面信息。返回的时候，会根据这些信息返回原来的页面
$nowpageid = addslashes($_REQUEST['nowpageid']);
$sortby    = addslashes($_REQUEST['sortby']);
$term_nid  = addslashes($_REQUEST['term_nid']);
$navitemed  = addslashes($_REQUEST['navitemed']);


$_REQUEST['ai_modifytime']  =date(Y . '-' . m . '-' . d . ' ' . H . '-' . i . '-' . s);
$_REQUEST['ai_authur']      = $_SESSION['username'];
$_REQUEST['ai_ip']          = $_SERVER["REMOTE_ADDR"];



//这里是涉及上传文件的部分：包含图片和附件。视频也应该用这种形式上传
//20220315同时把旧的文件，移动到delete中。
//统一设置一下保存图片的路径
$_uf['path']        = ROOT_PATH_ . "/uploadfiles/";

//创建删除文件存放文件夹
if(!file_exists($_uf['path'] ."/delete/")){
    mkdir($_uf['path'] ."/delete/",0777,true);
    chmod($_uf['path'] ."/delete/",0777);
}


//icon
if (is_uploaded_file($_FILES['icon']['tmp_name']))
{
    $_uf['upfile']       = $_FILES['icon'];
    $_info               = upload_file($_uf);
    $_REQUEST['ai_icon'] = $_info['name'];
    if(($_REQUEST['ai_icon'])&&($old_detail['icon']!="alpha.gif"))
    {
        rename($_uf['path'].$old_detail['icon'], $_uf['path'] ."delete/".$old_detail['icon']);
    }
}




//设置需要搜索的表格的前缀后缀
$table_Suffix = "unit";
$table        = $table_Prefix . $table_Suffix;


echo $sql=update_date($table,$_REQUEST,"nid",$new_detail_nid);
$query = mysql_query($sql) or die ($sql);



if($_REQUEST['content']){
//添加修改历史
$i_list['ai_modifytime'] = $_REQUEST['ai_modifytime'];
$i_list['ai_content']    = $_REQUEST['content'];
$i_list['ai_mid']        = $_REQUEST['nid'];
$i_list['ai_authur']     = $_SESSION['username'];
$i_list['ai_ip']         = $_SERVER['REMOTE_ADDR'];
$i_sql                   = insert_date($table_Prefix . 'unit_history', $i_list);

$query = mysql_query($i_sql) or die ("error:".mysql_error()."<br/>".$i_sql);
}


mysql_close($con);
?>


<script type="text/javascript">
    alert("输入信息已保存，点击确认返回继续操作.");
    document.location.href = "unit-list.php?nowpageid=<? echo $_GET["nowpageid"] ?>&sortby=<? echo $sortby?>&nid=<? echo $term_nid ?>&sys_part=unit&nav-itemed=unit"
</script>

